package com.github.yulichang.test.collection;

import com.github.yulichang.test.collection.entity.TableA;
import com.github.yulichang.test.collection.entity.TableB;
import com.github.yulichang.test.collection.mapper.TableAMapper;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

import java.util.List;

@ComponentScan(basePackages = "com.github.yulichang.test")
@SpringBootApplication
public class Application implements ApplicationRunner {

    public Application(TableAMapper tableAMapper) {
        this.tableAMapper = tableAMapper;
    }

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
    private   final TableAMapper tableAMapper;
    @Override
    public void run(ApplicationArguments args) throws Exception {

        int rows = 9; // 定义行数

        // 外层循环控制行数
        for(int i = 1; i <= rows; i++) {
            // 首先打印空格
            for(int j = 1; j <= rows - i; j++) {
                System.out.print(" "); // 每行星号前的空格数 = 总行数 - 当前行数
            }

            // 然后打印星号
            for(int k = 1; k <= (2*i - 1); k++) {
                System.out.print("*"); // 每行星号数 = 2 * 当前行数 - 1
            }

            // 每打印完一行后换行
            System.out.println();
        }

        MPJLambdaWrapper<TableA> mpjLambdaWrapper  =  new MPJLambdaWrapper();
        mpjLambdaWrapper.selectAll(TableA.class).selectCollection(TableB.class,TableA::getTableBS).selectCollection(TableB.class,TableA::getTableBS).leftJoin(TableB.class,TableB::getId,TableA::getId);
        List<TableA> list = tableAMapper.selectJoinList(TableA.class,mpjLambdaWrapper);
        System.out.println(list);
    }
}
